<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2023-01-13
 * Time: 19:14
 */

namespace App\controller\wechat;
use App\server\wechat\Work;
use support\Request;
use think\facade\Db;
use Webman\RedisQueue\Redis;
class User
{
    public function index(Request $request)
    {

    }

    public function list(Request $request)
    {

    }

    public function contact(Request $request)
    {
        $id=3;
        $w=new Work($id);
        $app=$w->getApp();
        $arr=$app->user->getDetailedDepartmentUsers(1,true);
        $user_list=[];
        if(isset($arr['userlist'])){
            $user_list=array_map(function($item){
                return $item['userid'];
            },$arr['userlist']);
        }
        Redis::send('work-contact', $user_list);
        return json($user_list);
    }
    public function contact1(Request $request)
    {
        $w=new Work(4);
        $app=$w->getApp();
        $arr=[];
        $userId = 'WuXiaoQing';
        $list=$app->external_contact->list($userId);
       /* $userId = 'yuruiqi';
        $arr[]=$app->external_contact->list($userId);*/
        foreach ($list['external_userid'] as $item) {
            $arr[]=$app->external_contact->get($item);
        }
         array_shift($list['external_userid']);

        $arr[]=$app->external_contact->batchGetByUser( $list['external_userid'], '', 10);

        return json([$arr,$list['external_userid']]);
    }
}